package com.ruoyi.report_lqn.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.syrw.annotation.FIllBasicInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.ruoyi.report_lqn.domain.bo.ReportLqnZrdydrhdjlbgxBsInfoBo;
import com.ruoyi.report_lqn.domain.vo.ReportLqnZrdydrhdjlbgxBsInfoVo;
import com.ruoyi.report_lqn.domain.ReportLqnZrdydrhdjlbgxBsInfo;
import com.ruoyi.report_lqn.mapper.ReportLqnZrdydrhdjlbgxBsInfoMapper;
import com.ruoyi.report_lqn.service.IReportLqnZrdydrhdjlbgxBsInfoService;

import java.util.List;
import java.util.Map;
import java.util.Collection;

/**
 * 沥青针入度、延度、软化点试验检测记录(改性沥青试验)Service业务层处理
 *
 * @author tll
 * @date 2024-09-12
 */
@RequiredArgsConstructor
@Service
public class ReportLqnZrdydrhdjlbgxBsInfoServiceImpl implements IReportLqnZrdydrhdjlbgxBsInfoService {

    private final ReportLqnZrdydrhdjlbgxBsInfoMapper baseMapper;

    /**
     * 查询沥青针入度、延度、软化点试验检测记录(改性沥青试验)
     */
    @Override
    @FIllBasicInfo
    public ReportLqnZrdydrhdjlbgxBsInfoVo queryById(Long excelId){
        return baseMapper.selectVoById(excelId);
    }

    /**
     * 查询沥青针入度、延度、软化点试验检测记录(改性沥青试验)列表
     */
    @Override
    public TableDataInfo<ReportLqnZrdydrhdjlbgxBsInfoVo> queryPageList(ReportLqnZrdydrhdjlbgxBsInfoBo bo, PageQuery pageQuery) {
        LambdaQueryWrapper<ReportLqnZrdydrhdjlbgxBsInfo> lqw = buildQueryWrapper(bo);
        Page<ReportLqnZrdydrhdjlbgxBsInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
        return TableDataInfo.build(result);
    }

    /**
     * 查询沥青针入度、延度、软化点试验检测记录(改性沥青试验)列表
     */
    @Override
    public List<ReportLqnZrdydrhdjlbgxBsInfoVo> queryList(ReportLqnZrdydrhdjlbgxBsInfoBo bo) {
        LambdaQueryWrapper<ReportLqnZrdydrhdjlbgxBsInfo> lqw = buildQueryWrapper(bo);
        return baseMapper.selectVoList(lqw);
    }

    private LambdaQueryWrapper<ReportLqnZrdydrhdjlbgxBsInfo> buildQueryWrapper(ReportLqnZrdydrhdjlbgxBsInfoBo bo) {
        Map<String, Object> params = bo.getParams();
        LambdaQueryWrapper<ReportLqnZrdydrhdjlbgxBsInfo> lqw = Wrappers.lambdaQuery();
        lqw.eq(bo.getTotalPage() != null, ReportLqnZrdydrhdjlbgxBsInfo::getTotalPage, bo.getTotalPage());
        lqw.eq(bo.getPage() != null, ReportLqnZrdydrhdjlbgxBsInfo::getPage, bo.getPage());
        lqw.eq(StringUtils.isNotBlank(bo.getJilbh()), ReportLqnZrdydrhdjlbgxBsInfo::getJilbh, bo.getJilbh());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancdwmc()), ReportLqnZrdydrhdjlbgxBsInfo::getJiancdwmc, bo.getJiancdwmc());
        lqw.eq(StringUtils.isNotBlank(bo.getGongcbwyt()), ReportLqnZrdydrhdjlbgxBsInfo::getGongcbwyt, bo.getGongcbwyt());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpmc()), ReportLqnZrdydrhdjlbgxBsInfo::getYangpmc, bo.getYangpmc());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpbh()), ReportLqnZrdydrhdjlbgxBsInfo::getYangpbh, bo.getYangpbh());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpsl()), ReportLqnZrdydrhdjlbgxBsInfo::getYangpsl, bo.getYangpsl());
        lqw.eq(StringUtils.isNotBlank(bo.getYangpzt()), ReportLqnZrdydrhdjlbgxBsInfo::getYangpzt, bo.getYangpzt());
        lqw.eq(bo.getYangpsj() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYangpsj, bo.getYangpsj());
        lqw.eq(StringUtils.isNotBlank(bo.getShiyjcrq()), ReportLqnZrdydrhdjlbgxBsInfo::getShiyjcrq, bo.getShiyjcrq());
        lqw.eq(StringUtils.isNotBlank(bo.getShiytjwd()), ReportLqnZrdydrhdjlbgxBsInfo::getShiytjwd, bo.getShiytjwd());
        lqw.eq(StringUtils.isNotBlank(bo.getShiytjsd()), ReportLqnZrdydrhdjlbgxBsInfo::getShiytjsd, bo.getShiytjsd());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancyj()), ReportLqnZrdydrhdjlbgxBsInfo::getJiancyj, bo.getJiancyj());
        lqw.eq(StringUtils.isNotBlank(bo.getPandyj()), ReportLqnZrdydrhdjlbgxBsInfo::getPandyj, bo.getPandyj());
        lqw.eq(StringUtils.isNotBlank(bo.getZhuyyqsbmcjbh()), ReportLqnZrdydrhdjlbgxBsInfo::getZhuyyqsbmcjbh, bo.getZhuyyqsbmcjbh());
        lqw.eq(StringUtils.isNotBlank(bo.getFujsm()), ReportLqnZrdydrhdjlbgxBsInfo::getFujsm, bo.getFujsm());
        lqw.eq(StringUtils.isNotBlank(bo.getBaobmc()), ReportLqnZrdydrhdjlbgxBsInfo::getBaobmc, bo.getBaobmc());
        lqw.eq(StringUtils.isNotBlank(bo.getBaobbh()), ReportLqnZrdydrhdjlbgxBsInfo::getBaobbh, bo.getBaobbh());
        lqw.eq(StringUtils.isNotBlank(bo.getGongcmc()), ReportLqnZrdydrhdjlbgxBsInfo::getGongcmc, bo.getGongcmc());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancr()), ReportLqnZrdydrhdjlbgxBsInfo::getJiancr, bo.getJiancr());
        lqw.eq(StringUtils.isNotBlank(bo.getJilr()), ReportLqnZrdydrhdjlbgxBsInfo::getJilr, bo.getJilr());
        lqw.eq(StringUtils.isNotBlank(bo.getFuhr()), ReportLqnZrdydrhdjlbgxBsInfo::getFuhr, bo.getFuhr());
        lqw.eq(bo.getRiq() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRiq, bo.getRiq());
        lqw.eq(StringUtils.isNotBlank(bo.getShebIds()), ReportLqnZrdydrhdjlbgxBsInfo::getShebIds, bo.getShebIds());
        lqw.eq(StringUtils.isNotBlank(bo.getJiancyjIds()), ReportLqnZrdydrhdjlbgxBsInfo::getJiancyjIds, bo.getJiancyjIds());
        lqw.eq(StringUtils.isNotBlank(bo.getPandyjIds()), ReportLqnZrdydrhdjlbgxBsInfo::getPandyjIds, bo.getPandyjIds());
        lqw.eq(StringUtils.isNotBlank(bo.getQuydd()), ReportLqnZrdydrhdjlbgxBsInfo::getQuydd, bo.getQuydd());
        lqw.eq(StringUtils.isNotBlank(bo.getLiqcd()), ReportLqnZrdydrhdjlbgxBsInfo::getLiqcd, bo.getLiqcd());
        lqw.eq(StringUtils.isNotBlank(bo.getLiqzl()), ReportLqnZrdydrhdjlbgxBsInfo::getLiqzl, bo.getLiqzl());
        lqw.eq(StringUtils.isNotBlank(bo.getLiqbh()), ReportLqnZrdydrhdjlbgxBsInfo::getLiqbh, bo.getLiqbh());
        lqw.eq(StringUtils.isNotBlank(bo.getZrdSybh1()), ReportLqnZrdydrhdjlbgxBsInfo::getZrdSybh1, bo.getZrdSybh1());
        lqw.eq(bo.getZrdWd1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdWd1, bo.getZrdWd1());
        lqw.eq(bo.getZrdCz11() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz11, bo.getZrdCz11());
        lqw.eq(bo.getZrdCz21() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz21, bo.getZrdCz21());
        lqw.eq(bo.getZrdCz31() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz31, bo.getZrdCz31());
        lqw.eq(bo.getZrdZrd1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdZrd1, bo.getZrdZrd1());
        lqw.eq(StringUtils.isNotBlank(bo.getZrdSybh2()), ReportLqnZrdydrhdjlbgxBsInfo::getZrdSybh2, bo.getZrdSybh2());
        lqw.eq(bo.getZrdWd2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdWd2, bo.getZrdWd2());
        lqw.eq(bo.getZrdCz12() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz12, bo.getZrdCz12());
        lqw.eq(bo.getZrdCz22() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz22, bo.getZrdCz22());
        lqw.eq(bo.getZrdCz32() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz32, bo.getZrdCz32());
        lqw.eq(bo.getZrdZrd2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdZrd2, bo.getZrdZrd2());
        lqw.eq(StringUtils.isNotBlank(bo.getZrdSybh3()), ReportLqnZrdydrhdjlbgxBsInfo::getZrdSybh3, bo.getZrdSybh3());
        lqw.eq(bo.getZrdWd3() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdWd3, bo.getZrdWd3());
        lqw.eq(bo.getZrdCz13() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz13, bo.getZrdCz13());
        lqw.eq(bo.getZrdCz23() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz23, bo.getZrdCz23());
        lqw.eq(bo.getZrdCz33() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz33, bo.getZrdCz33());
        lqw.eq(bo.getZrdZrd3() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdZrd3, bo.getZrdZrd3());
        lqw.eq(StringUtils.isNotBlank(bo.getZrdSybh4()), ReportLqnZrdydrhdjlbgxBsInfo::getZrdSybh4, bo.getZrdSybh4());
        lqw.eq(bo.getZrdWd4() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdWd4, bo.getZrdWd4());
        lqw.eq(bo.getZrdCz14() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz14, bo.getZrdCz14());
        lqw.eq(bo.getZrdCz24() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz24, bo.getZrdCz24());
        lqw.eq(bo.getZrdCz34() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz34, bo.getZrdCz34());
        lqw.eq(bo.getZrdZrd4() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdZrd4, bo.getZrdZrd4());
        lqw.eq(StringUtils.isNotBlank(bo.getZrdSybh5()), ReportLqnZrdydrhdjlbgxBsInfo::getZrdSybh5, bo.getZrdSybh5());
        lqw.eq(bo.getZrdWd5() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdWd5, bo.getZrdWd5());
        lqw.eq(bo.getZrdCz15() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz15, bo.getZrdCz15());
        lqw.eq(bo.getZrdCz25() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz25, bo.getZrdCz25());
        lqw.eq(bo.getZrdCz35() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdCz35, bo.getZrdCz35());
        lqw.eq(bo.getZrdZrd5() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdZrd5, bo.getZrdZrd5());
        lqw.eq(bo.getZrdPjz() != null, ReportLqnZrdydrhdjlbgxBsInfo::getZrdPjz, bo.getZrdPjz());
        lqw.eq(StringUtils.isNotBlank(bo.getYdZybh1()), ReportLqnZrdydrhdjlbgxBsInfo::getYdZybh1, bo.getYdZybh1());
        lqw.eq(bo.getYdWd1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYdWd1, bo.getYdWd1());
        lqw.eq(StringUtils.isNotBlank(bo.getYdSd1()), ReportLqnZrdydrhdjlbgxBsInfo::getYdSd1, bo.getYdSd1());
        lqw.eq(bo.getYdCz11() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYdCz11, bo.getYdCz11());
        lqw.eq(bo.getYdCz21() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYdCz21, bo.getYdCz21());
        lqw.eq(bo.getYdCz31() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYdCz31, bo.getYdCz31());
        lqw.eq(StringUtils.isNotBlank(bo.getYdZybh2()), ReportLqnZrdydrhdjlbgxBsInfo::getYdZybh2, bo.getYdZybh2());
        lqw.eq(bo.getYdWd2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYdWd2, bo.getYdWd2());
        lqw.eq(StringUtils.isNotBlank(bo.getYdSd2()), ReportLqnZrdydrhdjlbgxBsInfo::getYdSd2, bo.getYdSd2());
        lqw.eq(bo.getYdCz12() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYdCz12, bo.getYdCz12());
        lqw.eq(bo.getYdCz22() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYdCz22, bo.getYdCz22());
        lqw.eq(bo.getYdCz32() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYdCz32, bo.getYdCz32());
        lqw.eq(bo.getYdPjz1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYdPjz1, bo.getYdPjz1());
        lqw.eq(bo.getYdPjz2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getYdPjz2, bo.getYdPjz2());
        lqw.eq(StringUtils.isNotBlank(bo.getRhdSybh1()), ReportLqnZrdydrhdjlbgxBsInfo::getRhdSybh1, bo.getRhdSybh1());
        lqw.eq(StringUtils.isNotBlank(bo.getRhdMc1()), ReportLqnZrdydrhdjlbgxBsInfo::getRhdMc1, bo.getRhdMc1());
        lqw.eq(bo.getRhdKsjl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhdKsjl1, bo.getRhdKsjl1());
        lqw.eq(bo.getRhd1jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd1jl1, bo.getRhd1jl1());
        lqw.eq(bo.getRhd2jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd2jl1, bo.getRhd2jl1());
        lqw.eq(bo.getRhd3jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd3jl1, bo.getRhd3jl1());
        lqw.eq(bo.getRhd4jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd4jl1, bo.getRhd4jl1());
        lqw.eq(bo.getRhd5jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd5jl1, bo.getRhd5jl1());
        lqw.eq(bo.getRhd6jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd6jl1, bo.getRhd6jl1());
        lqw.eq(bo.getRhd7jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd7jl1, bo.getRhd7jl1());
        lqw.eq(bo.getRhd8jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd8jl1, bo.getRhd8jl1());
        lqw.eq(bo.getRhd9jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd9jl1, bo.getRhd9jl1());
        lqw.eq(bo.getRhd10jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd10jl1, bo.getRhd10jl1());
        lqw.eq(bo.getRhd11jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd11jl1, bo.getRhd11jl1());
        lqw.eq(bo.getRhd12jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd12jl1, bo.getRhd12jl1());
        lqw.eq(bo.getRhd13jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd13jl1, bo.getRhd13jl1());
        lqw.eq(bo.getRhd14jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd14jl1, bo.getRhd14jl1());
        lqw.eq(bo.getRhd15jl1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd15jl1, bo.getRhd15jl1());
        lqw.eq(bo.getRhdCz1() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhdCz1, bo.getRhdCz1());
        lqw.eq(StringUtils.isNotBlank(bo.getRhdSybh2()), ReportLqnZrdydrhdjlbgxBsInfo::getRhdSybh2, bo.getRhdSybh2());
        lqw.eq(StringUtils.isNotBlank(bo.getRhdMc2()), ReportLqnZrdydrhdjlbgxBsInfo::getRhdMc2, bo.getRhdMc2());
        lqw.eq(bo.getRhdKsjl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhdKsjl2, bo.getRhdKsjl2());
        lqw.eq(bo.getRhd1jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd1jl2, bo.getRhd1jl2());
        lqw.eq(bo.getRhd2jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd2jl2, bo.getRhd2jl2());
        lqw.eq(bo.getRhd3jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd3jl2, bo.getRhd3jl2());
        lqw.eq(bo.getRhd4jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd4jl2, bo.getRhd4jl2());
        lqw.eq(bo.getRhd5jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd5jl2, bo.getRhd5jl2());
        lqw.eq(bo.getRhd6jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd6jl2, bo.getRhd6jl2());
        lqw.eq(bo.getRhd7jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd7jl2, bo.getRhd7jl2());
        lqw.eq(bo.getRhd8jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd8jl2, bo.getRhd8jl2());
        lqw.eq(bo.getRhd9jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd9jl2, bo.getRhd9jl2());
        lqw.eq(bo.getRhd10jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd10jl2, bo.getRhd10jl2());
        lqw.eq(bo.getRhd11jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd11jl2, bo.getRhd11jl2());
        lqw.eq(bo.getRhd12jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd12jl2, bo.getRhd12jl2());
        lqw.eq(bo.getRhd13jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd13jl2, bo.getRhd13jl2());
        lqw.eq(bo.getRhd14jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd14jl2, bo.getRhd14jl2());
        lqw.eq(bo.getRhd15jl2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhd15jl2, bo.getRhd15jl2());
        lqw.eq(bo.getRhdCz2() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhdCz2, bo.getRhdCz2());
        lqw.eq(bo.getRhdPjz() != null, ReportLqnZrdydrhdjlbgxBsInfo::getRhdPjz, bo.getRhdPjz());
        return lqw;
    }

    /**
     * 新增沥青针入度、延度、软化点试验检测记录(改性沥青试验)
     */
    @Override
    public Boolean insertByBo(ReportLqnZrdydrhdjlbgxBsInfoBo bo) {
        ReportLqnZrdydrhdjlbgxBsInfo add = BeanUtil.toBean(bo, ReportLqnZrdydrhdjlbgxBsInfo.class);
        validEntityBeforeSave(add);
        boolean flag = baseMapper.insert(add) > 0;
        if (flag) {
            bo.setExcelId(add.getExcelId());
        }
        return flag;
    }

    /**
     * 修改沥青针入度、延度、软化点试验检测记录(改性沥青试验)
     */
    @Override
    public Boolean updateByBo(ReportLqnZrdydrhdjlbgxBsInfoBo bo) {
        ReportLqnZrdydrhdjlbgxBsInfo update = BeanUtil.toBean(bo, ReportLqnZrdydrhdjlbgxBsInfo.class);
        validEntityBeforeSave(update);
        return baseMapper.updateById(update) > 0;
    }

    /**
     * 保存前的数据校验
     */
    private void validEntityBeforeSave(ReportLqnZrdydrhdjlbgxBsInfo entity){
        //TODO 做一些数据校验,如唯一约束
    }

    /**
     * 批量删除沥青针入度、延度、软化点试验检测记录(改性沥青试验)
     */
    @Override
    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
        if(isValid){
            //TODO 做一些业务上的校验,判断是否需要校验
        }
        return baseMapper.deleteBatchIds(ids) > 0;
    }
}
